package mf.com.controller.sys;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import mf.com.Service.sys.SysMenuByRoleService;
import mf.com.dto.system.AssginMenuDto;
import mf.com.vo.common.Result;
import mf.com.vo.system.MenuByRoleVo;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: lmf
 * @Create: 2024/3/31 10:22
 * Description:  根据角色分配菜单控制层
 */
@RestController
@Tag(name = "根据角色分配菜单")
@RequestMapping(value = "/admin/system/sysRoleMenu")
public class SysMenuByRoleController {
    @Resource
    private SysMenuByRoleService sysMenuByRoleService;
    @PostMapping("/doAssign")
    @Operation(summary = "重新分配菜单")
    public Result<Integer> doAssign(@RequestBody AssginMenuDto assginMenuDto){
        System.out.println(assginMenuDto);
        return Result.success(sysMenuByRoleService.doAssign(assginMenuDto));
    }

    @GetMapping("/findSysRoleMenuByRoleId/{roleId}")
    @Operation(summary = "查询所有菜单及角色下的菜单id")
    public Result<MenuByRoleVo> selectByRoleId(@PathVariable("roleId") Long roleId){
        return Result.success(sysMenuByRoleService.selectByRoleId(roleId));
    }

}
